package com.example.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.example.struts.forms.LoginForm;

public class LoginAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		LoginForm loginForm = null;
		if (form instanceof LoginForm) {
			loginForm = (LoginForm) form;
		}

		if (loginForm.getUserName().trim().equalsIgnoreCase("admin")
				&& loginForm.getPassword().trim().equalsIgnoreCase("password")) {

			return mapping.findForward("sucess");

		}

		return mapping.findForward("error");

		// return super.execute(mapping, form, request, response);
	}

}
